package org.cloud.im.core.ws;

import org.cloud.im.core.ImConst;

/**
 * @Author: w.weidong.lin@abite.com
 * @Description: TODO
 * @Date: create in 2021/10/19 14:39
 */
public class WsConfig implements ImConst {

    private String charset = Http.CHARSET_NAME;

    private IWsMsgHandler wsMsgHandler;

    public WsConfig() {
    }

    public WsConfig(IWsMsgHandler wsMsgHandler) {
        this.wsMsgHandler = wsMsgHandler;
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    /**
     * @return the charset
     */
    public String getCharset() {
        return charset;
    }

    /**
     * @param charset the charset to set
     */
    public void setCharset(String charset) {
        this.charset = charset;
    }

    public IWsMsgHandler getWsMsgHandler() {
        return wsMsgHandler;
    }

    public void setWsMsgHandler(IWsMsgHandler wsMsgHandler) {
        this.wsMsgHandler = wsMsgHandler;
    }

    public static class Builder {

        private IWsMsgHandler wsMsgHandler;

        private String charset;

        public Builder wsMsgHandler(IWsMsgHandler wsMsgHandler) {
            this.wsMsgHandler = wsMsgHandler;
            return this;
        }

        public Builder charset(String charset) {
            this.charset = charset;
            return this;
        }

        public WsConfig build() {
            WsConfig wsConfig = new WsConfig(wsMsgHandler);
            wsConfig.setCharset(charset);
            return wsConfig;
        }
    }
}
